﻿using System;
using System.Text;
using System.Threading;

namespace NetWork
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string test = "abcde1234测试";
            Encoding encoding = Encoding.UTF8;
            char[] source = test.ToCharArray();
            int strLength = test.Length;
            int len = encoding.GetEncoder().GetByteCount(source, 0, strLength,false);
            byte[] result = new byte[len];
            encoding.GetEncoder().GetBytes(source, 0, strLength, result, 0, false);
            foreach (byte b in result) {
                Console.WriteLine(b);
            }
            Console.WriteLine();
            
            int deslen = encoding.GetDecoder().GetCharCount(result, 0, result.Length);
            char[] des = new char[deslen];
            encoding.GetDecoder().GetChars(result, 0, result.Length, des, 0);
            foreach (char c in des) {
                Console.WriteLine(c);
            }
            Console.WriteLine("\n");

            ThreadPool.QueueUserWorkItem(new WaitCallback(Threadproc));
            Console.WriteLine("主线程执行操作,然后暂停等待异步线程操作完成") ;
            Thread.Sleep(1000);
            Console.WriteLine("主线程已退出");
            Console.ReadLine();
        }

        static void Threadproc(object info) {
            Console.WriteLine("这是线程池中的线程输出的内容");
        }
    }
}
